/**
 * 配置参考: https://cli.vuejs.org/zh/config/
 */
const path = require('path');

module.exports = {
  parallel: false,
  publicPath: process.env.NODE_ENV === 'production' ? './' : '/',
  // module: {
  //   rules: [
  //     {
  //       test: /\.s[ac]ss$/i,
  //       use: ['style-loader', 'css-loader', 'sass-loader']
  //     }
  //   ]
  // },
  // chainWebpack: config => {
  //   const svgRule = config.module.rule('svg')
  //   svgRule.uses.clear()
  //   svgRule
  //     .test(/\.svg$/)
  //     .use('svg-sprite-loader')
  //     .loader('svg-sprite-loader')
  // },
  configureWebpack: (config) => {
    config.devtool = process.env.NODE_ENV === 'dev' ? 'source-map' : undefined;
  },
  chainWebpack: (config) => {
    // config.module
    //        .rule('js')
    //        .include
    //            .add(/node_modules/)
    //            .end()
    //        .use('babel-loader')
    //        .loader('babel-loader')
    //        .tap(options => {
    //             return {
    //                 presets: [
    //                     [
    //                         "@babel/preset-env",
    //                         {
    //                             "targets": {
    //                                 "node": "current"
    //                             }
    //                         }
    //                     ]
    //                 ]
    //             };
    //         });
    config.module
      .rule('vue')
      .test(/\.vue$/i)
      .use('vue-loader')
      .loader('vue-loader')
      .end()
      .rule('svg')
      .test(/\.svg$/i)
      .use('svg-sprite-loader')
      .loader('svg-sprite-loader')
      .end()
      .rule('css')
      .test(/\.s[ac]ss$/i)
      .use('style-loader')
      .loader('style-loader')
      .end()
      .use('css-loader')
      .loader('css-loader')
      .end()
      .use('sass-loader')
      .loader('sass-loader')
      .end();
  },
  css: {
    sourceMap: process.env.NODE_ENV === 'dev',
  },
  productionSourceMap: process.env.NODE_ENV === 'dev',
  devServer: {
    open: true,
    port: 8001,
    overlay: {
      errors: true,
      warnings: true,
    },
    proxy: {
      '/api': {
        // target: 'https://oss.blzdentalcloud.com/1/TemporaryFiles/blzmesh/',
        target: 'https://oss.blzdentalcloud.com/1/Layne_test/',
        
        // target: 'https://oss.blzdentalcloud.com/',
        ws: true, // /启用websockets
        changeOrigin: true, // 开启代理
        pathRewrite: {   // 重命名
          "^/api": "/"
        }
      },
    },
  },
  transpileDependencies: [
    'three/examples/jsm/controls/ArcballControls.js'
  ],
  configureWebpack: (config) => {
    config.devtool = process.env.NODE_ENV === 'dev' ? 'source-map' : undefined;

    config.module = {
      ...config.module,
      rules: [
        {
          test: /\.js$/,
          include: [
            path.resolve(__dirname, 'node_modules/three/examples/jsm/controls'),
            path.resolve(__dirname, 'src')
          ],
          use: {
            loader: 'babel-loader',
            options: {
              presets: ['@babel/preset-env'],
              plugins: [
                '@babel/plugin-proposal-optional-chaining',
                '@babel/plugin-proposal-nullish-coalescing-operator'
              ]
            }
          }
        }
      ]
    };
  },
};



